<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>美女一言在线查询余额🈲🔞clickme</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 600px;
            margin: 20px auto;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }
        h1 {
            color: #333;
            text-align: center;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
        }
        input[type="text"],
        input[type="number"] {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            width: 100%;
        }
        button:hover {
            background-color: #45a049;
        }
        #result {
            margin-top: 20px;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            text-align: center;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <h1>欢迎来到3A银行</h1>
    <form id="calculatorForm">
        <div class="form-group">
            <label>查询日期：</label>
            <input type="text" id="date" placeholder="YYYY-MM-DD" required>
        </div>
        <div class="form-group">
            <label>上次查询日期：</label>
            <input type="text" id="lastdate" placeholder="YYYY-MM-DD" required>
        </div>
        <div class="form-group">
            <label>账户余额：</label>
            <input type="number" id="benjin" step="0.01" placeholder="上次查询时的剩余金额" required>
        </div>
        <div class="form-group">
            <label>花费的金额：</label>
            <input type="number" id="cost" step="0.01" required>
        </div>
        <div class="form-group">
            <label>汇率(输入小数)：</label>
            <input type="number" id="exchangerate" step="0.01" placeholder="一单位账户余额可兑换花费金额的数量,譬如存的美元,花了人民币,汇率为一美元可兑换的人民币数量" required>
        </div>
        <div class="form-group">
            <label>存款利率(输入小数)：</label>
            <input type="number" id="interestrate" step="0.01" required>
        </div>
        <button type="submit">计算</button>
    </form>
    <div id="result"></div>

    <script>
        function cyybenjin(date, lastdate, benjin, cost, exchangerate, interestrate) {
            const date1 = new Date(date);
            const date2 = new Date(lastdate);
            const difference = date1 - date2; // 时间差毫秒数
            const days = difference / (1000 * 60 * 60 * 24); // 转换为天数
            
            const a = (days / 365) * interestrate * benjin + benjin - cost / exchangerate;
            return a.toFixed(2); // 保留两位小数
        }

        document.getElementById('calculatorForm').addEventListener('submit', function(e) {
            e.preventDefault();
            
            const date = document.getElementById('date').value;
            const lastdate = document.getElementById('lastdate').value;
            const benjin = parseFloat(document.getElementById('benjin').value);
            const cost = parseFloat(document.getElementById('cost').value);
            const exchangerate = parseFloat(document.getElementById('exchangerate').value);
            const interestrate = parseFloat(document.getElementById('interestrate').value);

            if (isNaN(benjin) || isNaN(cost) || isNaN(exchangerate) || isNaN(interestrate)) {
                alert("请输入有效的数字");
                return;
            }

            const result = cyybenjin(date, lastdate, benjin, cost, exchangerate, interestrate);
            document.getElementById('result').textContent = `账户余额为：${result} 元`;
        });
    </script>
</body>
</html>